/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import model.*;
import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.*;
/**
 *根据模型绘制出地图（图片）
 * @author 林景富
 */
public class GamePanel extends JPanel implements Observer{
   private Model model;
   public static int BOXSIZE=50;
   
   public GamePanel(Model model){
       this.model=model;
   }

    @Override
    public void update(Observable o, Object arg) {
        
    }
   
   @Override
    public void paintComponent(Graphics g){
        super.paintComponent(g);
        char[][] map=this.model.getMap();
        HashMap<Character,Image> imageMap=this.model.getImageMap();
       for(int i=0;i<map.length;i++){
           for(int j=0;j<map[0].length;j++){
               Image image=imageMap.get(map[i][j]);
               g.drawImage(image, j*BOXSIZE, i*BOXSIZE, 50, 50, this);
           }
       }
       System.out.println(map.length);
       System.out.println(map[0].length);
    }
}
